<!DOCTYPE html>
<html lang="zh-Hans" xmlns:th="http://www.thymeleaf.org">
<head>
	<title>修改患者基本信息</title>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chorme=1">
    <meta name="renderer" content="webkit">
	<script src="/static/cqzd/js/boot.js"></script>
	<script src="/static/cqzd/js/national.js"></script>
	<script src="/static/common/js/pinyinjs/dict/pinyin_dict_notone.js" data-site="remote"></script>
	<script src="/static/common/js/pinyinjs/pinyinUtil.js" data-site="remote"></script>
</head>
<body>
	<div style="padding-top:5px">
		<div id="basept_update_form">
			<input class="mini-hidden" name="action" value="update"/>
	        <input name="id" class="mini-hidden"/>
			<input class="mini-hidden" name="patientId"/>
			<input id="patientCode" class="mini-hidden" name="patientCode" class="mini-textbox mini-form-input" />

			<table style="width:100%;height:100%;table-layout:fixed;text-align: right;padding-right: 50px;line-height: 40px" class="mini-form-table" >
				<tr >
					<th class="mini-form-label"><label for="patientName$text">姓名：</label></th>
					<td >
						<input id="patientName" name="patientName" onvaluechanged="setPy(this)" class="mini-textbox mini-form-input" required="true" />
					</td>
					<th class="mini-form-label"><label for="patientCardId$text">姓名拼音：</label></th>
					<td>
						<input id="patientPy" name="patientPy"  class="mini-textbox  mini-form-input" />
					</td>

				</tr>
				<tr class="odd">
					<th class="mini-form-label"><label for="patientCardId$text">身份证：</label></th>
					<td>
						<input id="patientCardId" name="patientCardId" onvalidation="onIDCardsValidation" class="mini-textbox  mini-form-input" />
					</td>

					<th class="mini-form-label"><label for="patientRace$text">民族：</label></th>
					<td>
						<input id="patientRaceId" name="patientRaceId" class="mini-combobox mini-form-input txk-dict"  emptyText="请选择" textField="name" valueField="id" value="1"/>
					</td>
					<input id="patientRace" name="patientRace" class="mini-hidden"/>

				</tr>
				<tr class="odd">

					<th class="mini-form-label"><label for="patientSex$text">性别：</label></th>
					<td>
						<input id="patientSex" name="patientSex" class="mini-combobox mini-form-input txk-dict" value="f" emptyText="请选择" dict="CQ_BASE_SEX" />
					</td>
					<th class="mini-form-label"><label for="patientBirthday$text">出生日期：</label></th>
					<td>
						<input id="patientBirthday" name="patientBirthday" class="mini-datepicker  mini-form-input"  allowInput="false"/>
					</td>



				</tr>
				<tr>
					<th class="mini-form-label"><label for="patientEdu$text">学历：</label></th>
					<td>
						<input id="patientEduId" name="patientEduId" class="mini-combobox mini-form-input txk-dict" emptyText="请选择" dict="CQ_BASE_EDU"/>
					</td>
					<input id="patientEdu" name="patientEdu" class="mini-hidden"/>
					<th class="mini-form-label"><label for="patientOccupation$text">职业：</label></th>
					<td>
						<input id="patientOccupationId" name="patientOccupationId" class="mini-combobox mini-form-input txk-dict" emptyText="请选择" dict="CQ_BASE_OCCUPATION" showNullItem="true" nullItemText="无职业"/>
					</td>
					<input id="patientOccupation" name="patientOccupation" class="mini-hidden"/>


				</tr>
				<tr>
					<th class="mini-form-label"><label for="patientReligion$text">宗教信仰：</label></th>

					<td>
						<input id="patientReligionId" name="patientReligionId" class="mini-combobox mini-form-input txk-dict" emptyText="请选择" dict="CQ_BASE_RELIGION"/>
					</td>
					<input id="patientReligion" name="patientReligion" class="mini-hidden"/>
					<th class="mini-form-label"><label for="patientTel$text">电话号码：</label></th>
					<td>
						<input id="patientTel" name="patientTel" class="mini-textbox  mini-form-input" onvalidation="checkTel" />
					</td>

				</tr>
				<tr>
					<th class="mini-form-label"><label for="patientAddress$text">家庭住址：</label></th>
					<td>
						<input id="patientAddress" name="patientAddress" class="mini-textbox  mini-form-input"/>
					</td>
				</tr>


			</table>
			<div class=" oper-mini-toolbar" style="margin-top: 30px;padding-left: 37%" >
				<a class="mini-button" iconCls="icon-save" onclick="onOk()">保存</a>
				<span style="display:inline-block;width:25px;"></span>
				<a class="mini-button" iconCls="icon-cancel" onclick="onCancel()">取消</a>
			</div>
	    </div>
	</div>
    <script type="text/javascript">
		txkui.parse();
    	var moduleUlr="/cqzd/do/basepatient/";

        var form = new mini.Form("basept_update_form");
		mini.get("patientRaceId").setData(nation_data);
        function SaveData() {         
			
            form.validate();
            if (form.isValid() == false) return;
            var data=form.getData(false,true);

			var edu= mini.get('patientEduId').getSelected();
			data.patientEdu=edu ? edu.text:null;


			var religion=mini.get('patientReligionId').getSelected();
			data.patientReligion =religion ? religion.text:null;

			var occ = mini.get('patientOccupationId').getSelected();
            data.patientOccupation = occ ? occ.text : null;

			var race = mini.get('patientRaceId').getSelected();
			data.patientRace = race ? race.name:null;

			if(mini.get("patientBirthday").value==""){
				delete data.patientBirthday;
			}

			HttpUtil.post(moduleUlr+"update", data, function (text) {
				if(text.errMsg){
					mini.alert("修改失败"+text.errmsg);
					return;
				}else {
					mini.alert("修改成功","成功",function(){
						txkui.closeWindow("ok");
					});
				}

	        });
        }


		function setPy(nameVal){

			nameVal.value=nameVal.value.replace(/[^\a-zA-Z0-9\u4E00-\u9FA5. _\-]/g,'');
			mini.get('patientPy').setValue(pinyinUtil.getFirstLetter(nameVal.value))
		}

		function onIDCardsValidation(e) {
			if (e.isValid && e.value) {
				var regIdCard = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;
				if (!regIdCard.test(e.value)) {
					e.errorText = "身份证输入有误";
					e.isValid = false;
				}
			}
		}

		function checkTel(e) {
			if (e.isValid && e.value) {
				var pattern = /(^(0\d{2,3}-\d{7,8}))|(^1[3456789]\d{9}$)/;
				if (!pattern.test(e.value)) {
					e.errorText = "电话号码输入有误";
					e.isValid = false;
				}
			}
		}

        function onOk(e) {

            SaveData();
        }
        function onCancel(e) {
        	txkui.closeWindow("cancel",form);
        }

		function SetData(dataP) {
			//跨页面传递的数据对象，克隆后才可以安全使用
			var data = mini.clone(dataP);
			form.setData(data);
		}

    </script>
</body>
</html>